const { mongoose } = require("./db");
const Schema = mongoose.Schema;


const userSchema = new Schema({
  username: String, //用户名
  avatarUrl: {
    type: String,
    default: "",
  }, //头像
  real_name: {
    type: String,
    default: "",
  }, //真实姓名
  sex: {
    type: String,
    default: "",
  }, //性别
  phone: {
    type: String,
    default: "",
  }, //联系电话
  Idcard: {
    type: String,
    default: "",
  }, //身份证件
  address: {
    type: String,
    default: "",
  }, //现居住址
  date_birth: {
    type: Date,
    default: "",
  }, //出生日期
  nation: {
    type: String,
    default: "",
  }, //民族
  marital_status: {
    type: String,
    default: "",
  }, //婚姻状态
  emergency_contact: {
    type: String,
    default: "",
  }, //紧急联系人
  emergency_contact_phone: {
    type: String,
    default: "",
  }, //紧急联系人电话
  permanent_address: {
    type: String,
    default: "",
  }, //户口地
  house_address: {
    type: String,
    default: "",
  }, //家庭住址
  symptom_label: {
    type: Array,
    default: [],
  }, //标签
  member_family_id: [
    {
      type: mongoose.Types.ObjectId,
      ref: "wxuser",
    },
  ], //关联家庭成员

  // 健康信息
  stature: {
    type: String,
    default: "",
  }, //身高
  weight: {
    type: String,
    default: "",
  }, //体重
  blood_type: {
    type: String,
    default: "",
  }, //血型
  RH_negative: {
    type: String,
    default: "",
  }, //RH阴性

  // 历史
  allergies: {
    type: String,
    default: "",
  }, //过敏史
  previous: {
    type: String,
    default: "",
  }, //既往史
  Medical_history: {
    type: String,
    default: "",
  }, //过敏史
  Family_history: {
    type: String,
    default: "",
  }, //过敏史

  status: {
    //状态
    type: Boolean,
    default: true,
  },
  nickName: {
    type: String,
    default: "",
  }, //微信名称
  openid: {
    type: String,
    default: "",
  }, //openid
});

const userModel = mongoose.model("wxuser", userSchema);

module.exports = { userModel };
